package com.ez.supervise.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.FileDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.biz.File;

public class FileDaoImpl extends BaseDaoImpl implements FileDao {

    public void insert(Object file) {
	sqlMapClientTemplate.insert("biz.insertFile", file);
    }

    public Object get(Long id) {
	return (File) sqlMapClientTemplate.queryForObject("biz.getFileById", id);
    }

    public void update(Object org) {
	sqlMapClientTemplate.update("biz.updateFile", org);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.update("biz.deleteFile", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.FileDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findFileByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findFileByCount", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.FileDao#findByPage(com.ez.supervise.core.Page)
     */
    public List findFileByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findFileByPage", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.FileDao#findAll()
     */
    public List findAll() {
	return getSqlMapClientTemplate().queryForList("biz.findAll");
    }

    public List findFileByPublish() {
	return getSqlMapClientTemplate().queryForList("biz.findFileByPublish");
    }

    public void publish(Long id, String publishStatus) {
	Map map = new HashMap();
	map.put("id", id);
	map.put("status", publishStatus);
	getSqlMapClientTemplate().update("biz.publishFile", map);
	
    }

}
